import 'dart:convert' show json;

class MusicMan {
  int code;
  String message;
  List<PersonalItem> result;

  MusicMan.fromParams({this.code, this.message, this.result});

  factory MusicMan(jsonStr) => jsonStr == null
      ? null
      : jsonStr is String
          ? new MusicMan.fromJson(json.decode(jsonStr))
          : new MusicMan.fromJson(jsonStr);

  MusicMan.fromJson(jsonRes) {
    code = jsonRes['code'];
    message = jsonRes['message'];
    result = jsonRes['result'] == null ? null : [];

    for (var resultItem in result == null ? [] : jsonRes['result']) {
      result.add(
          resultItem == null ? null : new PersonalItem.fromJson(resultItem));
    }
  }

  @override
  String toString() {
    return '{"code": $code,"message": ${message != null ? '${json.encode(message)}' : 'null'},"result": $result}';
  }
}

class PersonalItem {
  int songid;
  String author;
  String link;
  String lrc;
  String pic;
  String title;
  String type;
  String url;

  PersonalItem.fromParams(
      {this.songid,
      this.author,
      this.link,
      this.lrc,
      this.pic,
      this.title,
      this.type,
      this.url});

  PersonalItem.fromJson(jsonRes) {
    songid = jsonRes['songid'];
    author = jsonRes['author'];
    link = jsonRes['link'];
    lrc = jsonRes['lrc'];
    pic = jsonRes['pic'];
    title = jsonRes['title'];
    type = jsonRes['type'];
    url = jsonRes['url'];
  }

  @override
  String toString() {
    return '{"songid": $songid,"author": ${author != null ? '${json.encode(author)}' : 'null'},"link": ${link != null ? '${json.encode(link)}' : 'null'},"lrc": ${lrc != null ? '${json.encode(lrc)}' : 'null'},"pic": ${pic != null ? '${json.encode(pic)}' : 'null'},"title": ${title != null ? '${json.encode(title)}' : 'null'},"type": ${type != null ? '${json.encode(type)}' : 'null'},"url": ${url != null ? '${json.encode(url)}' : 'null'}}';
  }
}
